package com.zheng.study.base.bean.search.page;

import com.zheng.study.base.bean.search.SearchEnum;
import com.zheng.study.base.bean.search.projection.Projection;

/**
 * 查询 - 参数 - Page
 * ============================================================================
 * author : fallenpanda
 * createDate:  2018/6/11 。
 * ============================================================================
 */
public abstract class Page {

	protected final SearchEnum.ResultType resultType;
	protected final Projection projection;

	protected Page(SearchEnum.ResultType resultType, Projection projection) {
		this.resultType = resultType;
		this.projection = projection;
	}

	public SearchEnum.ResultType getResultType() {
		return resultType;
	}

	public Projection getProjection() {
		return projection;
	}

	public abstract static class Builder<T extends Page, B extends Builder<T, B>>{
		private B theBuilder;

		protected SearchEnum.ResultType resultType;
		protected Projection projection;

		public B setResultType(SearchEnum.ResultType resultType) {
			this.resultType = resultType;
			return theBuilder;
		}

		public B setProjection(Projection projection) {
			this.projection = projection;
			return theBuilder;
		}

		protected Builder(){
			theBuilder = getThis();
		}

		protected abstract B getThis();
		public abstract T build();

	}

}
